﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ComTools.DesignPattern.ProcessingPipeline
{
    /// <summary>
    /// 处理一系列任务的管线抽象接口
    /// </summary>
    /// <typeparam name="TStepParameter">调用处理步骤方法的参数类型</typeparam>
    /// <typeparam name="TLastStepProccessResult">传递给下一步骤的当前步骤的处理结果类型</typeparam>
    /// <typeparam name="TProcessResult">表示步骤处理完毕通知外部的结果类型</typeparam>
    public abstract class AProcessingStep<TStepParameter, TLastStepProccessResult, TProcessResult>
    {
        /// <summary>
        /// 日志处理
        /// </summary>
        public virtual Action<string> Log { get; set; }

        /// <summary>
        /// 用来通知外部的执行步骤完的返回值
        /// </summary>
        public virtual Action<TProcessResult> ReturnResultAction { get; set; }

        /// <summary>
        /// 传递给下一步骤的当前步骤的处理结果
        /// </summary>
        public virtual TLastStepProccessResult LastStepProccessResult { get; set; } = default(TLastStepProccessResult);

        /// <summary>
        /// 处理当前步骤
        /// </summary>
        /// <typeparam name="TStepParameter">处理当前步骤的参数类型</typeparam>
        /// <param name="parameter">参数</param>
        public abstract void ProcessCurrentStep(TStepParameter parameter);

        /// <summary>
        /// 处理下一步
        /// </summary>
        /// <typeparam name="TStepParameter">处理当前步骤的参数类型</typeparam>        
        /// <param name="parameter">处理当前步骤的参数</param>        
        public virtual void ProcessNextStep(TStepParameter parameter)
        {
            throw new NotImplementedException();
        }
    }
}
